﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MemcachedProviders.Cache;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void buttonSet_Click(object sender, EventArgs e)
        {
           var flag=   DistCache.Add(this.textBoxKey.Text, this.textBoxValue.Text);
           if (flag)
           {
               this.textBoxKey.BackColor = Color.White;
               this.textBoxValue.BackColor = Color.White;

               MessageBox.Show("设置成功");
           }
           else
           {
               MessageBox.Show("保存失败");
           }
        }

        private void buttonGet_Click(object sender, EventArgs e)
        {
            object obj = DistCache.Get(this.textBoxKey.Text);
            if (obj != null)
            {
                this.textBoxValue.Text = obj.ToString();
                this.textBoxKey.BackColor = Color.Gray;
                this.textBoxValue.BackColor = Color.Gray;
                MessageBox.Show("获取成功");
            }
            else
            {
                this.textBoxValue.Text = "没有这个Key值";
                this.textBoxKey.BackColor = Color.Gray;
                this.textBoxValue.BackColor = Color.Gray;
            }
        }
    }
}
